using System.Collections.Generic;
using System.Text;

namespace OracleInternal.SqlAndPlsqlParser.LocalParsing
{
	internal class OracleLpSetExpressionSubquery : OracleLpSubquery
	{
		private OracleLpSubquery m_vLeftSubquery;

		private OracleLpSubquery m_vRightSubquery;

		private OracleLpSetOperator m_vSetOperator;

		public override OracleLpSubqueryType SubqueryType => OracleLpSubqueryType.SetExpression;

		public OracleLpSubquery LeftSubquery
		{
			get
			{
				return m_vLeftSubquery;
			}
			internal set
			{
				m_vLeftSubquery = value;
				m_vLeftSubquery.Parent = this;
			}
		}

		public OracleLpSubquery RightSubquery
		{
			get
			{
				return m_vRightSubquery;
			}
			internal set
			{
				m_vRightSubquery = value;
				m_vRightSubquery.Parent = this;
			}
		}

		public OracleLpSetOperator SetOperator
		{
			get
			{
				return m_vSetOperator;
			}
			internal set
			{
				m_vSetOperator = value;
			}
		}

		public OracleLpSetExpressionSubquery(OracleLpStatementElement parent)
			: base(parent)
		{
		}

		public override void Resolve()
		{
			List<OracleLpColumnDescriptor> columnDescriptors = m_vLeftSubquery.ColumnDescriptors;
			_ = m_vRightSubquery.ColumnDescriptors;
			m_vColumnDescriptors = columnDescriptors;
		}

		public override void RetrieveNamedObjectReferences(OracleLpStatement statement)
		{
			m_vLeftSubquery.RetrieveNamedObjectReferences(statement);
			m_vRightSubquery.RetrieveNamedObjectReferences(statement);
		}

		internal override void ToString(StringBuilder sb)
		{
			string depthIndent = base.DepthIndent;
			base.ToString(sb);
			sb.Append(depthIndent);
			sb.Append("Left subquery:\n");
			m_vLeftSubquery.ToString(sb);
			sb.Append(depthIndent);
			sb.Append("Set operator: ");
			sb.Append(SetOperator.ToString());
			sb.Append('\n');
			sb.Append(depthIndent);
			sb.Append("Right subquery:\n");
			m_vRightSubquery.ToString(sb);
			sb.Append('\n');
		}
	}
}
